#include"MainAlgorithm.h"
#define std ::std::
#define cv ::cv::



int main()
{
	std cout << "MOONOTUS MESSAGE::Start Successd" << std endl;
	TCHAR namein[4095];
	cv VideoCapture video;
	while (1)
	{
		initgraph(0, 0);
		cleardevice();
		InputBox(namein, 8192, L"MediaSet", L"MesiaPath", L"Input media name");
		closegraph();
		std string name = wstr_str(namein);
		video = cv VideoCapture(name);
		if (video.isOpened())
		{
			std cout << "MOONOTUS MESSAGE::OPEN VIDEO SUCCESSED" << std endl;
			break;
		}
		video.release();
		std cerr << "MOONOTUS ERROR::VIDEO OPEN FAILED" << std endl;
	}
	cv Mat frame;
	cv Mat frame_;
	char press;
	int width = video.get(cv CAP_PROP_FRAME_WIDTH) / 2;
	int height = video.get(cv CAP_PROP_FRAME_HEIGHT) / 2;
	while (video.read(frame))
	{
		frame_ = frame;
		resize(frame_, frame_, cv Size(width, height));
		cv imshow("MediaPlayer", frame_);
		press = cv waitKey(25);
		if (press == ' ' || press == 'q' || press == 'Q')
		{
			std cout << "MOONOTUS MESSAGE::EXIT" << std endl;
			return 0;
		}
		frame.release();
		frame_.release();
	}
	video.release();

	return 0;
}